package cn.onestoplog.currEx.yahoo;

import java.util.HashMap;

public abstract class BaseCurrencyConverter implements CurrencyConverter {

	public HashMap<String, CurrencyPair> getConversionMatrix(String... currencies) throws Exception {
        // Build pair combinations
        int size = currencies.length;
        CurrencyPair[] currencyPairs = new CurrencyPair[size-1];
        int index = 0;
        for (int i = 1; i < size; i++) {
            //for (int j = 0; j < size; j++) {
                currencyPairs[index++] = new CurrencyPair(currencies[0], currencies[i]);
           // }
        }
        // Get currencies information
        
        convert(currencyPairs);
        // Build matrix
//        CurrencyPair[][] matrix = new CurrencyPair[size][size];
        HashMap<String, CurrencyPair> datas = new HashMap<String, CurrencyPair>();
        index = 0;
        for (int i = 1; i < size; i++) {
            //for (int j = 0; j < size; j++) {
//                matrix[i][j] = i != j ? currencyPairs[index] : null;
               // if(i != j )
                	datas.put(currencies[0]+"/"+currencies[i], currencyPairs[index]);
                index++;
           // }
        }
//        return matrix;
        return datas;
    }

}
